<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        
        <meta name="author" content="隐星魂 (Roy.Sun)">
        
        <link rel="shortcut icon" href="../../../img/favicon.ico">
        <title>02-工程配置指南 - 玄武操作系统</title>
        <link href="../../../css/bootstrap.min.css" rel="stylesheet">
        <link href="../../../css/font-awesome.min.css" rel="stylesheet">
        <link href="../../../css/base.css" rel="stylesheet">
        <link rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.3/styles/color-brewer.min.css">

        <script src="../../../js/jquery-1.10.2.min.js" defer></script>
        <script src="../../../js/bootstrap.min.js" defer></script>
        <script src="https://cdn.staticfile.org/highlight.js/10.0.3/highlight.min.js"></script>
        <script>hljs.initHighlightingOnLoad();</script> 
    </head>

    <body>
        <div class="navbar fixed-top navbar-expand-lg navbar-dark bg-primary">
            <div class="container">
                <a class="navbar-brand" href="../../..">玄武操作系统</a>
                <!-- Expander button -->
                <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbar-collapse">
                    <span class="navbar-toggler-icon"></span>
                </button>

                <!-- Expanded navigation -->
                <div id="navbar-collapse" class="navbar-collapse collapse">
                        <!-- Main navigation -->
                        <ul class="nav navbar-nav">
                            <li class="navitem">
                                <a href="../../.." class="nav-link">主页</a>
                            </li>
                            <li class="navitem">
                                <a href="../../../License/" class="nav-link">开源协议</a>
                            </li>
                            <li class="dropdown active">
                                <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">快速开发指南 <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    
  <li class="dropdown-submenu">
    <a href="#" class="dropdown-item">STM32</a>
    <ul class="dropdown-menu">
            
<li>
    <a href="../../stm32/01-Envsetup-Guide/" class="dropdown-item">01-开发环境搭建指南</a>
</li>
            
<li>
    <a href="../../stm32/02-atkh743/" class="dropdown-item">02-正点原子阿波罗H743开发板上手指南</a>
</li>
            
<li>
    <a href="../../stm32/03-fk429m/" class="dropdown-item">03-反客F429核心板上手指南</a>
</li>
            
<li>
    <a href="../../stm32/04-atkf103core/" class="dropdown-item">04-正点原子F103核心板上手指南</a>
</li>
            
<li>
    <a href="../../stm32/05-atkf407core/" class="dropdown-item">05-正点原子F407核心板上手指南</a>
</li>
            
<li>
    <a href="../../stm32/06-WeActH750/" class="dropdown-item">06-微行电子H750开发板上手指南</a>
</li>
            
<li>
    <a href="../../stm32/07-Project-From-Scratch-Guide/" class="dropdown-item">07-自定义工程配置指南</a>
</li>
    </ul>
  </li>
                                    
  <li class="dropdown-submenu">
    <a href="#" class="dropdown-item">GD32</a>
    <ul class="dropdown-menu">
            
<li>
    <a href="../01-Envsetup-Guide/" class="dropdown-item">01-开发环境搭建指南</a>
</li>
            
<li>
    <a href="./" class="dropdown-item active">02-工程配置指南</a>
</li>
    </ul>
  </li>
                                    
  <li class="dropdown-submenu">
    <a href="#" class="dropdown-item">GD32V</a>
    <ul class="dropdown-menu">
            
<li>
    <a href="../../gd32v/01-Envsetup-Guide/" class="dropdown-item">01-开发环境搭建指南</a>
</li>
            
<li>
    <a href="../../gd32v/02-Project-Setup-Guide/" class="dropdown-item">02-工程配置指南</a>
</li>
    </ul>
  </li>
                                    
  <li class="dropdown-submenu">
    <a href="#" class="dropdown-item">NXP S32K</a>
    <ul class="dropdown-menu">
            
<li>
    <a href="../../s32k/01-Envsetup-Guide/" class="dropdown-item">01-开发环境搭建指南</a>
</li>
            
<li>
    <a href="../../s32k/02-Project-Setup-Guide/" class="dropdown-item">02-工程配置指南</a>
</li>
    </ul>
  </li>
                                    
  <li class="dropdown-submenu">
    <a href="#" class="dropdown-item">玄武内核模块</a>
    <ul class="dropdown-menu">
            
<li>
    <a href="../../xwko/01-XuanWuKO-Guide/" class="dropdown-item">01-上手指南</a>
</li>
    </ul>
  </li>
                                </ul>
                            </li>
                            <li class="dropdown">
                                <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">应用手册 <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    
<li>
    <a href="../../../UserManual/00-Index/" class="dropdown-item">0.目录</a>
</li>
                                    
<li>
    <a href="../../../UserManual/01-Brief/" class="dropdown-item">1.简介</a>
</li>
                                    
<li>
    <a href="../../../UserManual/02-Basic-System-Architecture/" class="dropdown-item">2.系统基本架构</a>
</li>
                                    
<li>
    <a href="../../../UserManual/03-Build-System/" class="dropdown-item">3.构建系统</a>
</li>
                                    
<li>
    <a href="../../../UserManual/04-Boot-Flow/" class="dropdown-item">4.启动流程</a>
</li>
                                    
<li>
    <a href="../../../UserManual/05-IRQ/" class="dropdown-item">5.中断控制</a>
</li>
                                    
<li>
    <a href="../../../UserManual/06-SKD/" class="dropdown-item">6.调度器</a>
</li>
                                    
<li>
    <a href="../../../UserManual/07-Thread/" class="dropdown-item">7.线程</a>
</li>
                                    
<li>
    <a href="../../../UserManual/08-SWT/" class="dropdown-item">8.软件定时器</a>
</li>
                                    
<li>
    <a href="../../../UserManual/09-PM/" class="dropdown-item">9.电源管理</a>
</li>
                                    
<li>
    <a href="../../../UserManual/10-Lock/" class="dropdown-item">10.锁</a>
</li>
                                    
<li>
    <a href="../../../UserManual/11-Sync/" class="dropdown-item">11.同步</a>
</li>
                                    
<li>
    <a href="../../../UserManual/12-MM/" class="dropdown-item">12.内存管理</a>
</li>
                                    
<li>
    <a href="../../../UserManual/13-C-Lib/" class="dropdown-item">13.玄武C库</a>
</li>
                                </ul>
                            </li>
                            <li class="dropdown">
                                <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">Lua手册 <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    
<li>
    <a href="../../../LuaManual/00-Index/" class="dropdown-item">0.目录</a>
</li>
                                    
<li>
    <a href="../../../LuaManual/01-Brief/" class="dropdown-item">1.简介</a>
</li>
                                    
<li>
    <a href="../../../LuaManual/02-XWXT/" class="dropdown-item">2.全局导出表</a>
</li>
                                    
  <li class="dropdown-submenu">
    <a href="#" class="dropdown-item">3.XWOS内核</a>
    <ul class="dropdown-menu">
            
<li>
    <a href="../../../LuaManual/03-XWOS/01-SDK/" class="dropdown-item">3.1.线程库</a>
</li>
            
<li>
    <a href="../../../LuaManual/03-XWOS/02-Spinlock/" class="dropdown-item">3.2.自旋锁库</a>
</li>
            
<li>
    <a href="../../../LuaManual/03-XWOS/03-Seqlock/" class="dropdown-item">3.3.顺序锁库</a>
</li>
            
<li>
    <a href="../../../LuaManual/03-XWOS/04-Mutex/" class="dropdown-item">3.4.互斥锁库</a>
</li>
            
<li>
    <a href="../../../LuaManual/03-XWOS/05-Semaphore/" class="dropdown-item">3.5.信号量库</a>
</li>
            
<li>
    <a href="../../../LuaManual/03-XWOS/06-Condition/" class="dropdown-item">3.6.条件量库</a>
</li>
            
<li>
    <a href="../../../LuaManual/03-XWOS/07-Flag/" class="dropdown-item">3.7.事件标志库</a>
</li>
            
<li>
    <a href="../../../LuaManual/03-XWOS/08-Barrier/" class="dropdown-item">3.8.线程栅栏库</a>
</li>
            
<li>
    <a href="../../../LuaManual/03-XWOS/09-Selector/" class="dropdown-item">3.9.信号选择器库</a>
</li>
            
<li>
    <a href="../../../LuaManual/03-XWOS/10-PM/" class="dropdown-item">3.10.电源管理</a>
</li>
    </ul>
  </li>
                                    
  <li class="dropdown-submenu">
    <a href="#" class="dropdown-item">4.玄武Lua函数库</a>
    <ul class="dropdown-menu">
            
<li>
    <a href="../../../LuaManual/04-XWLIB/01-Bitmap/" class="dropdown-item">4.1.位图</a>
</li>
    </ul>
  </li>
                                    
  <li class="dropdown-submenu">
    <a href="#" class="dropdown-item">5.设备栈</a>
    <ul class="dropdown-menu">
            
<li>
    <a href="../../../LuaManual/05-XWDS/01-Soc/" class="dropdown-item">5.1.SOC</a>
</li>
            
<li>
    <a href="../../../LuaManual/05-XWDS/02-GPIO/" class="dropdown-item">5.2.GPIO</a>
</li>
            
<li>
    <a href="../../../LuaManual/05-XWDS/03-UART/" class="dropdown-item">5.3.UART</a>
</li>
            
<li>
    <a href="../../../LuaManual/05-XWDS/04-SPI-Master/" class="dropdown-item">5.4.SPI Master</a>
</li>
            
<li>
    <a href="../../../LuaManual/05-XWDS/05-IIC-Master/" class="dropdown-item">5.5.IIC Master</a>
</li>
    </ul>
  </li>
                                </ul>
                            </li>
                            <li class="dropdown">
                                <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">移植笔记 <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    
<li>
    <a href="../../../PortingNote/00-Index/" class="dropdown-item">目录</a>
</li>
                                    
<li>
    <a href="../../../PortingNote/01-Porting-Note/" class="dropdown-item">移植笔记</a>
</li>
                                    
  <li class="dropdown-submenu">
    <a href="#" class="dropdown-item">ARM-Cortex-M</a>
    <ul class="dropdown-menu">
            
<li>
    <a href="../../../PortingNote/02-ARM-Cortex-M/01-ARM-Cortex-M-Porting-Note/" class="dropdown-item">架构移植笔记</a>
</li>
            
<li>
    <a href="../../../PortingNote/02-ARM-Cortex-M/02-STM32-Porting-Note/" class="dropdown-item">STM32</a>
</li>
    </ul>
  </li>
                                    
  <li class="dropdown-submenu">
    <a href="#" class="dropdown-item">RISC-V</a>
    <ul class="dropdown-menu">
            
<li>
    <a href="../../../PortingNote/03-RISC-V/01-GD32V-Porting-Note/" class="dropdown-item">GD32V</a>
</li>
    </ul>
  </li>
                                </ul>
                            </li>
                            <li class="dropdown">
                                <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">规范 <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    
<li>
    <a href="../../../Specification/00-Index/" class="dropdown-item">目录</a>
</li>
                                    
<li>
    <a href="../../../Specification/01-Git-Commit-Specification/" class="dropdown-item">git-commit规范</a>
</li>
                                    
<li>
    <a href="../../../Specification/02-Version-Branch-Specification/" class="dropdown-item">版本分支规范</a>
</li>
                                </ul>
                            </li>
                        </ul>

                    <ul class="nav navbar-nav ml-auto">
                        <li class="nav-item">
                            <a href="#" class="nav-link" data-toggle="modal" data-target="#mkdocs_search_modal">
                                <i class="fa fa-search"></i> 搜索
                            </a>
                        </li>
                            <li class="nav-item">
                                <a rel="prev" href="../01-Envsetup-Guide/" class="nav-link">
                                    <i class="fa fa-arrow-left"></i> 上一篇
                                </a>
                            </li>
                            <li class="nav-item">
                                <a rel="next" href="../../gd32v/01-Envsetup-Guide/" class="nav-link">
                                    下一篇 <i class="fa fa-arrow-right"></i>
                                </a>
                            </li>
                    </ul>
                </div>
            </div>
        </div>

        <div class="container">
            <div class="row">
                    <div class="col-md-3"><div class="navbar-light navbar-expand-md bs-sidebar hidden-print affix" role="complementary">
    <div class="navbar-header">
        <button type="button" class="navbar-toggler collapsed" data-toggle="collapse" data-target="#toc-collapse" title="Table of Contents">
            <span class="fa fa-angle-down"></span>
        </button>
    </div>

    
    <div id="toc-collapse" class="navbar-collapse collapse card bg-secondary">
        <ul class="nav flex-column">
            
            <li class="nav-item" data-level="1"><a href="#_1" class="nav-link">工程配置指南</a>
              <ul class="nav flex-column">
              </ul>
            </li>
            
            <li class="nav-item" data-level="1"><a href="#1" class="nav-link">1.搭建开发环境</a>
              <ul class="nav flex-column">
              </ul>
            </li>
            
            <li class="nav-item" data-level="1"><a href="#2" class="nav-link">2.通过导入方式创建工程</a>
              <ul class="nav flex-column">
            <li class="nav-item" data-level="2"><a href="#21" class="nav-link">2.1.下载工程</a>
              <ul class="nav flex-column">
              </ul>
            </li>
            <li class="nav-item" data-level="2"><a href="#22" class="nav-link">2.2 工程改名</a>
              <ul class="nav flex-column">
              </ul>
            </li>
            <li class="nav-item" data-level="2"><a href="#23" class="nav-link">2.3.导入工程</a>
              <ul class="nav flex-column">
              </ul>
            </li>
            <li class="nav-item" data-level="2"><a href="#24" class="nav-link">2.4.工程设置</a>
              <ul class="nav flex-column">
              </ul>
            </li>
              </ul>
            </li>
            
            <li class="nav-item" data-level="1"><a href="#3" class="nav-link">3.修改芯片配置</a>
              <ul class="nav flex-column">
              </ul>
            </li>
            
            <li class="nav-item" data-level="1"><a href="#4" class="nav-link">4.编译工程</a>
              <ul class="nav flex-column">
              </ul>
            </li>
            
            <li class="nav-item" data-level="1"><a href="#5" class="nav-link">5.调试</a>
              <ul class="nav flex-column">
              </ul>
            </li>
            
            <li class="nav-item" data-level="1"><a href="#6firmware-library" class="nav-link">6.增加官方Firmware Library</a>
              <ul class="nav flex-column">
              </ul>
            </li>
            
            <li class="nav-item" data-level="1"><a href="#7" class="nav-link">7.增加用户软件</a>
              <ul class="nav flex-column">
              </ul>
            </li>
            
            <li class="nav-item" data-level="1"><a href="#8" class="nav-link">8.附录</a>
              <ul class="nav flex-column">
              </ul>
            </li>
        </ul>
    </div>
</div></div>
                    <div class="col-md-9" role="main">

<h1 id="_1">工程配置指南</h1>
<hr />
<h1 id="1">1.搭建开发环境</h1>
<ul>
<li><a href="../01-Envsetup-Guide/">开发环境搭建指南</a></li>
</ul>
<hr />
<h1 id="2">2.通过导入方式创建工程</h1>
<h2 id="21">2.1.下载工程</h2>
<ul>
<li>gd32f103<ul>
<li>仓库：<a href="https://gitee.com/xwos/gd32f103rbtmpl.git">https://gitee.com/xwos/gd32f103rbtmpl.git</a></li>
<li>命令：</li>
</ul>
</li>
</ul>
<pre><code class="sh">git clone --recursive https://gitee.com/xwos/gd32f103rbtmpl.git
cd gd32f103rbtmpl
unzip project-template.zip
</code></pre>

<ul>
<li>gd32f303<ul>
<li>仓库：<a href="https://gitee.com/xwos/gd32f303cctmpl.git">https://gitee.com/xwos/gd32f303cctmpl.git</a></li>
<li>命令：</li>
</ul>
</li>
</ul>
<pre><code class="sh">git clone --recursive https://gitee.com/xwos/gd32f303cctmpl.git
cd gd32f303cctmpl
unzip project-template.zip
</code></pre>

<ul>
<li>工程需要放在Eclipse的工作目录内（即Eclipse启动时指定的目录），
    并按照上面的命令将<strong>“project-template.zip”</strong>解压到工程目录中，
    这些文件为工程模板。</li>
</ul>
<p><img alt="img" src="../res/figure/Eclipse-Project-Folder.png" title="工程目录" /></p>
<h2 id="22">2.2 工程改名</h2>
<p>若需要对工程改名，应该在导入工程前修改以下内容：</p>
<ul>
<li>文件夹名改成<strong>新的工程名</strong>；</li>
<li>在<code>brd/cfg/XuanWuOS.h</code>文件中，将<code>XuanWuOS_CFG_BOARD</code>的定义改成<strong>新的工程名</strong>；</li>
<li>在<code>.cproject</code>文件中，将所有的<code>gd32f103rbtmpl</code>都替换成<strong>新的工程名</strong>；</li>
<li>在<code>.project</code>文件中，将所有的<code>gd32f103rbtmpl</code>都替换成<strong>新的工程名</strong>；</li>
<li>在<code>.settings</code>文件夹中，将所有文件中的所有的<code>gd32vf103tmpl</code>都替换成<strong>新的工程名</strong>；</li>
</ul>
<h2 id="23">2.3.导入工程</h2>
<p>打开菜单<strong>File --&gt; Import... --&gt; General --&gt; Projects from Folder or Archive</strong></p>
<p><img alt="img" src="../res/figure/Eclipse-Import.png" title="导入工程" /></p>
<h2 id="24">2.4.工程设置</h2>
<h3 id="_2">文件编码设置</h3>
<p>菜单 <strong>Project &#x2013;&gt; Properties &#x2013;&gt; Resource</strong></p>
<p><img alt="img" src="../res/figure/Eclipse-Properties-Resource.png" title="文件编码设置" /></p>
<h3 id="_3">编译设置</h3>
<ul>
<li>菜单<strong>Project &#x2013;&gt; Properties</strong></li>
<li><strong>Debug</strong>和<strong>Release</strong>两个配置都需要增加：</li>
</ul>
<p><img alt="img" src="../res/figure/Eclipse-Properties-Build-Settings.png" title="编译设置" /></p>
<p><img alt="img" src="../res/figure/Eclipse-Properties-Build-Behavior.png" title="编译行为" /></p>
<h3 id="_4">环境变量设置</h3>
<ul>
<li>菜单<strong>Project &#x2013;&gt; Properties &#x2013;&gt; C/C++ Build &#x2013;&gt; Environment</strong>。</li>
<li>点击<strong>Restore Defaults</strong>先恢复一次默认设置。</li>
<li>设置：<ul>
<li><strong>WKSPC</strong>: <code>../../../${ConfigName}</code>；</li>
<li><strong>~V</strong>: <code>1</code>；</li>
<li><strong>~D</strong>: <strong>Debug</strong>配置为<code>1</code>，<strong>Release</strong>配置为<code>0</code>。</li>
</ul>
</li>
<li><strong>Debug</strong>和<strong>Release</strong>两个配置都需要增加。</li>
</ul>
<p><img alt="img" src="../res/figure/Eclipse-Properties-Build-Env.png" title="Build-Env配置" /></p>
<h1 id="3">3.修改芯片配置</h1>
<p>模板中的默认芯片可能与用户的不一样，需要按实际情况进行修改。</p>
<ul>
<li><code>brd/bdl/bdl.mk</code>：根据芯片密度，修改定义。按照官方手册：<ul>
<li>GD32F101xx和GD32F103xx的闪存存储器容量16K到128K字节之间的产品称作中密度产品，
    需要修改成<code>-DGD32F10X_MD</code>；</li>
<li>GD32F101xx和GD32F103xx的闪存存储器容量256K到512K字节之间的产品称作高密度产品，
    需要修改成<code>-DGD32F10X_HD</code>；</li>
<li>GD32F101xx和GD32F103xx的闪存存储器容量大于512K节的产品称作超高密度产品，
    需要修改成<code>-DGD32F10X_XD</code>；</li>
<li>GD32F105xx和GD32F107xx微控制器称作互联型产品，
    需要修改成<code>-DGD32F10X_CL</code>。</li>
</ul>
</li>
<li><code>brd/cfg/XuanWuOS.lds</code>：根据芯片的Flash与RAM情况，调整memory的参数：<ul>
<li>中断向量表、Image信息块以及代码区加起来不能超过Flash区域；</li>
<li>数据区、中断栈加起来不能超过RAM区域。</li>
</ul>
</li>
</ul>
<pre><code>MEMORY {
        flash_mr (rx): org = 0x08000000, len = 128k /* Flash的首地址与大小 */
        ocram_mr (rwx): org = 0x20000000, len = 20k /* RAM的首地址与大小 */

        /* 中断向量表 */
        /* 将加载地址和运行地址配置为相同表示中断向量表不需要从Flash中拷贝到
           内存 */
        vctbl_lmr (rx): org = 0x08000000, len = 1024 /* 加载地址 */
        vctbl_vmr (rw): org = 0x08000000, len = 1024 /* 运行地址 */

        /* Image信息块 */
        /* 玄武OS会在bin文件中增加一个数据块，记录Image的基本信息，
           这一块信息放在中断向量表 */
        image_description_mr (rx): org = 0x08000400, len = 1k /* image description */

        /* 代码区 */
        /* 所有的可执行代码 */
        code_mr (rx): org = 0x08000800, len = 126k /* .xwos.vctbl &amp;
                                                      .xwos.init.text &amp;
                                                      .xwos.init.rodata &amp;
                                                      .xwos.exit.text &amp;
                                                      .xwos.exit.rodata &amp;
                                                      .xwos.isr.text &amp;
                                                      .xwos.text &amp;
                                                      .xwos.rodata &amp;
                                                      .text &amp;
                                                      .rodata */

        /* 数据区 */
        /* 全局变量、栈、堆 */
        data_mr (arw): org = 0x20000000, len = 18k /* .data, .bss &amp; .heap */

        /* 中断栈 */
        /* 剩下的内存留给处理器执行中断函数时使用 */
        xwos_stk_mr (rw): org = 0x20004800, len = 2k /* xwos stack */
}
</code></pre>

<h1 id="4">4.编译工程</h1>
<p><img alt="img" src="../res/figure/Eclipse-Build.png" title="编译" /></p>
<h1 id="5">5.调试</h1>
<h3 id="daplink">设置DAPLink仿真器的访问权限</h3>
<pre><code class="sh">sudo gedit /etc/udev/rules.d/81-daplink.rules
</code></pre>

<p>输入下面内容后，保存退出。</p>
<pre><code>ATTRS{idProduct}==&quot;f001&quot;, ATTRS{idVendor}==&quot;0d28&quot;, MODE=&quot;666&quot;
ATTRS{idProduct}==&quot;f002&quot;, ATTRS{idVendor}==&quot;0d28&quot;, MODE=&quot;666&quot;
ATTRS{idProduct}==&quot;2722&quot;, ATTRS{idVendor}==&quot;0d28&quot;, MODE=&quot;666&quot;
ATTRS{idProduct}==&quot;0204&quot;, ATTRS{idVendor}==&quot;0d28&quot;, MODE=&quot;666&quot;
</code></pre>

<p>重启系统或使用下面命令使得配置生效：</p>
<pre><code class="sh">sudo udevadm control --reload
</code></pre>

<h3 id="pyocddaplink">设置pyocd，使用DAPLink调试</h3>
<ul>
<li>Main选择卡中选择好工程，以及ELF文件。</li>
</ul>
<p><img alt="img" src="../res/figure/pyocd-Main.png" title="Main" /></p>
<ul>
<li>Debugger选择卡<ul>
<li>需要设置pyocd与arm-none-eabi-gdb两个程序的路径，如果用户
    是按照之前的指南安装环境的，这两个程序可以在系统路径中被找到；</li>
<li>需要设定复位的方式，若仿真器与目标板之间由Reset连线，可选择Hardware，否则
    选择Software(SYSRESETREQ)；</li>
<li>通过--pack选项为pyocd指定DFP包的路径，DFP包可在GD的官网中下载的<strong>keil5 ADD-ON</strong>包中找到；</li>
<li>通过--target选项为pyocd指定器件名称，器件的名称通常是芯片名称"T6"之前的部分，
    例如：<strong>gd32f303cc</strong>、<strong>gd32f103rb</strong>、<strong>gd32f103ve</strong>等。</li>
</ul>
</li>
</ul>
<p><img alt="img" src="../res/figure/pyocd-Debugger.png" title="Debugger" /></p>
<ul>
<li>Startup选择卡中可设置一个启动断点，通常设置为<code>arch_isr_reset</code>或<code>xwos_main</code>。</li>
</ul>
<p><img alt="img" src="../res/figure/pyocd-Startup.png" title="Startup" /></p>
<h3 id="_5">重启调试</h3>
<p>调试过程可能需要复位系统，可以在右键菜单中选择Restart，有时还需要按一下复位按键。</p>
<p><img alt="img" src="../res/figure/pyocd-Restart.png" title="重新开始调试" /></p>
<hr />
<h1 id="6firmware-library">6.增加官方Firmware Library</h1>
<p>工程模板中已经将官方的Firmware Library以<strong>玄武模块</strong>的形式集成到系统中。
有关<strong>玄武模块</strong>可以参考<a href="../../../UserManual/03-Build-System/">应用手册——构建系统</a>。</p>
<ul>
<li>模块路径：gd32fmwlib</li>
<li>Makefile：gd32fmwlib/xwmo.mk</li>
<li>编译开关：<code>OEMCFG_gd32fmwlib</code>，位于<code>brd/cfg/oem.h</code></li>
</ul>
<hr />
<h1 id="7">7.增加用户软件</h1>
<p>工程模板中已经有一个名为<code>app</code>的OEM模块，用户可在其中增加自己的C代码：</p>
<ul>
<li>模块路径：app</li>
<li>Makefile：app/xwmo.mk</li>
<li>编译开关：<code>OEMCFG_app</code>，位于<code>brd/cfg/oem.h</code></li>
</ul>
<hr />
<h1 id="8">8.附录</h1>
<ul>
<li>上一篇 <a href="../01-Envsetup-Guide/">开发环境搭建指南</a></li>
</ul></div>
            </div>
        </div>

        <footer class="col-md-12">
            <hr>
            <p>Documentation built with <a href="https://www.mkdocs.org/">MkDocs</a>.</p>
        </footer>
        <script>
            var base_url = "../../..",
                shortcuts = {"help": 191, "next": 78, "previous": 80, "search": 83};
        </script>
        <script src="../../../js/base.js" defer></script>
        <script src="../../../search/main.js" defer></script>

        <div class="modal" id="mkdocs_search_modal" tabindex="-1" role="dialog" aria-labelledby="searchModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="searchModalLabel">搜索</h4>
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            </div>
            <div class="modal-body">
                <p>
                    在这里所有文档：
                </p>
                <form>
                    <div class="form-group">
                        <input type="search" class="form-control" placeholder="搜索..." id="mkdocs-search-query" title="Type search term here">
                    </div>
                </form>
                <div id="mkdocs-search-results"></div>
            </div>
            <div class="modal-footer">
            </div>
        </div>
    </div>
</div><div class="modal" id="mkdocs_keyboard_modal" tabindex="-1" role="dialog" aria-labelledby="keyboardModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="keyboardModalLabel">Keyboard Shortcuts</h4>
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            </div>
            <div class="modal-body">
              <table class="table">
                <thead>
                  <tr>
                    <th style="width: 20%;">Keys</th>
                    <th>Action</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <td class="help shortcut"><kbd>?</kbd></td>
                    <td>Open this help</td>
                  </tr>
                  <tr>
                    <td class="next shortcut"><kbd>n</kbd></td>
                    <td>Next page</td>
                  </tr>
                  <tr>
                    <td class="prev shortcut"><kbd>p</kbd></td>
                    <td>Previous page</td>
                  </tr>
                  <tr>
                    <td class="search shortcut"><kbd>s</kbd></td>
                    <td>Search</td>
                  </tr>
                </tbody>
              </table>
            </div>
            <div class="modal-footer">
            </div>
        </div>
    </div>
</div>

    </body>
</html>
